package com.siwei.mes.service.laboratory.factory.material;

import com.siwei.mes.enums.TestProjectEnum;
import com.siwei.mes.service.laboratory.factory.material.admixtrue.*;
import com.siwei.mes.service.laboratory.factory.material.cement.*;
import com.siwei.mes.service.laboratory.factory.material.coarse.*;
import com.siwei.mes.service.laboratory.factory.material.fine.*;
import com.siwei.mes.service.laboratory.factory.material.fly.*;
import com.siwei.mes.service.laboratory.factory.material.slag.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 原材料工厂选择器
 *
 * @Description: 原材料工厂选择器
 * @Version: 1.0
 * @author: mlchen
 * @date: 2025/3/29 16:26
 */
@Service
public class MaterialLaboratoryFactorySelector {
    private static final Logger log = LoggerFactory.getLogger("laboratory");

    private static final Map<String, MaterialLaboratoryFactory> FACTORY_MAP = new HashMap<>();
    @Resource
    private CementAdxFactory cementAdxFactory;
    @Resource
    private CementBbmjFactory cementBbmjFactory;
    @Resource
    private CementBzcdFactory cementBzcdFactory;
    @Resource
    private CementMdFactory cementMdFactory;
    @Resource
    private CementNjsjFactory cementNjsjFactory;
    @Resource
    private CementXdFactory cementXdFactory;
    @Resource
    private CementQdcdFactory cementQdcdFactory;

    @Resource
    private AdmixtureHglFactory admixtureHglFactory;
    @Resource
    private AdmixtureJslFactory admixtureJslFactory;
    @Resource
    private AdmixtureMdFactory admixtureMdFactory;
    @Resource
    private AdmixtureNjsjzcFactory admixtureNjsjzcFactory;
    @Resource
    private AdmixturePhzFactory admixturePhzFactory;
    @Resource
    private AdmixtureQslbFactory admixtureQslbFactory;
    @Resource
    private AdmixtureTld1hjsbhlFactory admixtureTld1hjsbhlFactory;

    @Resource
    private CoarseBgmdFactory coarseBgmdFactory;
    @Resource
    private CoarseDjmdFactory coarseDjmdFactory;
    @Resource
    private CoarseHnklFactory coarseHnklFactory;
    @Resource
    private CoarseHnlFactory coarseHnlFactory;
    @Resource
    private CoarseJmmdFactory coarseJmmdFactory;
    @Resource
    private CoarseSfxFactory coarseSfxFactory;
    @Resource
    private CoarseYszzbFactory coarseYszzbFactory;
    @Resource
    private CoarseZpzklhlFactory coarseZpzklhlFactory;

    @Resource
    private FineBgmdFactory fineBgmdFactory;
    @Resource
    private FineDjmdFactory fineDjmdFactory;
    @Resource
    private FineHnlFactory fineHnlFactory;
    @Resource
    private FineJmmdFactory fineJmmdFactory;
    @Resource
    private FineLlzhlFactory fineLlzhlFactory;
    @Resource
    private FineNkhlFactory fineNkhlFactory;
    @Resource
    private FineSfxFactory fineSfxFactory;
    @Resource
    private FineYszzbFactory fineYszzbFactory;
    @Resource
    private FineHslFactory fineHslFactory;
    @Resource
    private FineJslddFactory fineJslddFactory;

    @Resource
    private FlyAdxFactory flyAdxFactory;
    @Resource
    private FlyHslFactory flyHslFactory;
    @Resource
    private FlyHxzsFactory flyHxzsFactory;
    @Resource
    private FlySslFactory flySslFactory;
    @Resource
    private FlySyhlFactory flySyhlFactory;
    @Resource
    private FlyXdFactory flyXdFactory;
    @Resource
    private FlyXslbFactory flyXslbFactory;
    @Resource
    private FlyYlyhgFactory flyYlyhgFactory;

    @Resource
    private SlagBbmjFactory slagBbmjFactory;
    @Resource
    private SlagHslFactory slagHslFactory;
    @Resource
    private SlagHxzsFactory slagHxzsFactory;
    @Resource
    private SlagLddbFactory slagLddbFactory;
    @Resource
    private SlagSslFactory slagSslFactory;
    @Resource
    private SlagSyhlFactory slagSyhlFactory;
    @Resource
    private SlagYpmdFactory slagYpmdFactory;

    @PostConstruct
    public void init() {
        /**水泥相关的*/
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_ADX.getCode(), cementAdxFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_BBMJ.getCode(), cementBbmjFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_BZCD.getCode(), cementBzcdFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_MD.getCode(), cementMdFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_NJSJ.getCode(), cementNjsjFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_XD.getCode(), cementXdFactory);
        FACTORY_MAP.put(TestProjectEnum.CEMENT_PARAM_QDCD.getCode(), cementQdcdFactory);

        /**外加剂相关的*/
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_HGL.getCode(), admixtureHglFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_JSL.getCode(), admixtureJslFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_MD.getCode(), admixtureMdFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_NJSJZC.getCode(), admixtureNjsjzcFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_PHZ.getCode(), admixturePhzFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_QSLB.getCode(), admixtureQslbFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_ADMIXTURE_PARAM_WJJ_TLD1HJSBHL.getCode(), admixtureTld1hjsbhlFactory);
        /**粗骨料相关的*/
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_BGMD.getCode(), coarseBgmdFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_DJMD.getCode(), coarseDjmdFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_HNKL.getCode(), coarseHnklFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_HNL.getCode(), coarseHnlFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_JMMD.getCode(), coarseJmmdFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_SFX.getCode(), coarseSfxFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_YSZZB.getCode(), coarseYszzbFactory);
        FACTORY_MAP.put(TestProjectEnum.COARSE_AGGREGATE_PARAM_CGL_ZPZKLHL.getCode(), coarseZpzklhlFactory);
        /**细骨料相关的*/
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_BGMD.getCode(), fineBgmdFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_DJMD.getCode(), fineDjmdFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_HNL.getCode(), fineHnlFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_JMMD.getCode(), fineJmmdFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_LLZHL.getCode(), fineLlzhlFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_NKHL.getCode(), fineNkhlFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_SFX.getCode(), fineSfxFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_YSZZB.getCode(), fineYszzbFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_HSL.getCode(), fineHslFactory);
        FACTORY_MAP.put(TestProjectEnum.FINE_AGGREGATE_PARAM_XGL_JSLDD.getCode(), fineJslddFactory);
        /**粉煤灰相关的*/
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_ADX.getCode(), flyAdxFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_HSL.getCode(), flyHslFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_HXZS.getCode(), flyHxzsFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_SSL.getCode(), flySslFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_SYHL.getCode(), flySyhlFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_XD.getCode(), flyXdFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_XSLB.getCode(), flyXslbFactory);
        FACTORY_MAP.put(TestProjectEnum.FLY_ASK_PARAM_FMH_YLYHG.getCode(), flyYlyhgFactory);
        /**矿渣粉相关的*/
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_BBMJ.getCode(), slagBbmjFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_HSL.getCode(), slagHslFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_HXZS.getCode(), slagHxzsFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_LDDB.getCode(), slagLddbFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_SSL.getCode(), slagSslFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_SYHL.getCode(), slagSyhlFactory);
        FACTORY_MAP.put(TestProjectEnum.SLAG_PARAM_KZF_YPMD.getCode(), slagYpmdFactory);

        log.info("初始化【协会原材料】工厂选择器完成！初始化个数：【{}】", FACTORY_MAP.size());
    }

    public static MaterialLaboratoryFactory getFactory(String testProjectCode) {
        return FACTORY_MAP.get(testProjectCode);
    }
}
